package cn.gson.boot.controller;

import cn.gson.boot.model.pojos.*;
import cn.gson.boot.model.service.FaHuoService;
import cn.gson.boot.model.service.HeTongService;
import cn.gson.boot.model.service.ShenHeService;
import cn.gson.boot.model.service.TuiHuoService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/shenhe")
public class ShenHeController {
    @Autowired
    ShenHeService shenHeService;

    //查看所有审核
    @RequestMapping("/selectAllShenHe")
    @ResponseBody
    public Map<String,Object> selectAllFaHuo(String tj, String tj2, String tj3, Integer pageNumm, Integer pageSizee){
        System.err.println("条件："+pageNumm);System.err.println("条件："+pageSizee);
        System.err.println("条件："+tj);
        Page<Object> objects = PageHelper.startPage(pageNumm, pageSizee);
        if(tj.equals("全部数据")){
            tj = null;
        }
        if(tj2.equals("全部数据")){
            tj2 = null;
        }
        List<Shenhe> list = shenHeService.selectAllShenHe(tj,tj2,tj3);
        Map<String,Object> map = new HashMap();
        map.put("total", objects.getTotal());
        map.put("list", list);
        return map;
    }

    //查询有审核权限的员工（现在还没写好）
    @RequestMapping("/selectSHemp")
    @ResponseBody
    public List<User> selectSHemp(){
        return shenHeService.selectSHemp();
    }

    //确定审核
    @RequestMapping("/queDingShenHe")
    @ResponseBody
    public void queDingShenHe(@RequestBody Shenhe shenhe){
        shenHeService.queDingShenHe(shenhe);
    }

    //根据退货id查看退货
    @RequestMapping("/selectTuiHuoByThId")
    @ResponseBody
    public Tuihuo selectTuiHuoByThId(Integer thId){
        return shenHeService.selectTuiHuoByThId(thId);
    }
    //根据换货id查看换货
    @RequestMapping("/selectHuanHuoByThId")
    @ResponseBody
    public Huanhuo selectHuanHuoByThId(Integer hhId){
        return shenHeService.selectHuanHuoByThId(hhId);
    }


    @RequestMapping("/selectQuotationDetailss")
    @ResponseBody
    public List<Quotationdetails> selectQuotationDetailss(Integer quotationId){
        return shenHeService.selectQuotationDetailss(quotationId);
    }

    //根据销售费用id查找销售费用
    @RequestMapping("/selectXSFYbysellId")
    @ResponseBody
    public Sell selectXSFYbysellId(Integer sellId){
        return shenHeService.selectXSFYbysellId(sellId);
    }
}
